#include "tinyxml2\tinyxml2.h"
#include "stdio.h"
#include "XCollada.h"
#define DEBUG_XCOLLADA 1
int main(int argc, char *argv[])
{
#if DEBUG_XCOLLADA
#else
	if(argc < 2)
	{
		printf("Not enough params");
		return 1;
	}
#endif
#if DEBUG_XCOLLADA
	FILE *f = fopen("F:\\GoogleProject\\WP8Core\\Data\\jet2.DAE", "rt");
#else
	FILE *f = fopen(argv[0], "rt");
#endif
	if(f == NULL)
	{
		printf("File not found: %s", argv[0]);
		return 1;
	}

	fseek (f, 0, SEEK_END);
	long size = ftell(f);
	fseek (f, 0, SEEK_SET);
	char* buffer = new char[size+1];
	buffer[size] = 0;
	fread(buffer, 1, size, f);
	fclose(f);
	XColladaNamespace::XCollada xcollada;
	xcollada.InitFromOpenCollada(buffer);
	delete[] buffer;
#if DEBUG_XCOLLADA
	xcollada.WriteToXColladaFile("F:\\GoogleProject\\WP8Core\\RTE\\RTE\\RTE\\Assets\\XDAE\\jet.XDAE");
#else
	xcollada.WriteToXColladaFile(argv[1]);
#endif
	return 0;
}